<html>
<head><meta charset="utf-8"><title>Remove `Replace unwrap with match` assist · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html">Remove `Replace unwrap with match` assist</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="244925987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244925987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244925987">(Jul 05 2021 at 11:48)</a>:</h4>
<p>with <code>inline_call</code> working on methods and eliminating useless bindings after <a href="https://github.com/rust-analyzer/rust-analyzer/pull/9474">https://github.com/rust-analyzer/rust-analyzer/pull/9474</a> the assist doesn't really need to exist anymore I believe.<br>
<a href="/user_uploads/4715/lUCw8s808Mhahy_3SoceZ6v6/image.png">image.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/lUCw8s808Mhahy_3SoceZ6v6/image.png" title="image.png"><img src="/user_uploads/4715/lUCw8s808Mhahy_3SoceZ6v6/image.png"></a></div><p>I'm also not sure why the match gets indented that weirdly but I think thats just our reindentation logic not working well enough for matches. We really are in dire need of a formatter <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span></p>



<a name="244926131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244926131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244926131">(Jul 05 2021 at 11:49)</a>:</h4>
<p>Lol, haven't considered that... That's cool, let's remove the assist then!</p>



<a name="244926416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244926416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244926416">(Jul 05 2021 at 11:52)</a>:</h4>
<p>Truthfully spoken this was part of my motivation for implementing the elimination, since now this basically works for all the functions on options and results like <code>map_or</code>, <code>unwrap_or_else</code>, etc</p>



<a name="244926453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244926453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244926453">(Jul 05 2021 at 11:52)</a>:</h4>
<p><a href="/user_uploads/4715/w_f2ew6oL-mWFZ84mUsxKuzn/image.png">image.png</a> <br>
Maybe not for all of them yet <span aria-label="rolling eyes" class="emoji emoji-1f644" role="img" title="rolling eyes">:rolling_eyes:</span></p>
<div class="message_inline_image"><a href="/user_uploads/4715/w_f2ew6oL-mWFZ84mUsxKuzn/image.png" title="image.png"><img src="/user_uploads/4715/w_f2ew6oL-mWFZ84mUsxKuzn/image.png"></a></div>



<a name="244926523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244926523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244926523">(Jul 05 2021 at 11:53)</a>:</h4>
<p>Let's use <code>.unwrap</code> as an example in the doc-string for inline_call -- it's somewhat non-obvious that you can do this. You can <code># //- minicore: result</code> I think.</p>



<a name="244926663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244926663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244926663">(Jul 05 2021 at 11:55)</a>:</h4>
<p>Oh ye that's a good point</p>



<a name="244927327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244927327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244927327">(Jul 05 2021 at 12:01)</a>:</h4>
<p>Oh wait, inlining an unwrap on a result will give you incorrect code as result uses a private function for the panicking path</p>



<a name="244927422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244927422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244927422">(Jul 05 2021 at 12:02)</a>:</h4>
<p>Though I guess that isnt really a problem? <a href="/user_uploads/4715/5ieDCUtqxxbrYF-TXQJxpgJq/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/5ieDCUtqxxbrYF-TXQJxpgJq/image.png" title="image.png"><img src="/user_uploads/4715/5ieDCUtqxxbrYF-TXQJxpgJq/image.png"></a></div>



<a name="244927476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244927476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244927476">(Jul 05 2021 at 12:03)</a>:</h4>
<p>I think that's fine, yeah</p>



<a name="244928432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Remove%20%60Replace%20unwrap%20with%20match%60%20assist/near/244928432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist.html#244928432">(Jul 05 2021 at 12:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="300586">Lukas Wirth</span> <a href="#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Remove.20.60Replace.20unwrap.20with.20match.60.20assist/near/244926453">said</a>:</p>
<blockquote>
<p><a href="/user_uploads/4715/w_f2ew6oL-mWFZ84mUsxKuzn/image.png">image.png</a> <br>
Maybe not for all of them yet <span aria-label="rolling eyes" class="emoji emoji-1f644" role="img" title="rolling eyes">:rolling_eyes:</span></p>
</blockquote>
<p>ooh, applying inline closures next? <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>